//AC
//http://acm.hdu.edu.cn/showproblem.php?pid=1008
#include<stdio.h>

int TimeSpan(int currentState,int newState)
{

  if(currentState<newState)
    {
      return (newState - currentState)*6 + 5;
    }
  else if(currentState > newState) 
    {
      return (currentState - newState)*4 + 5;
    }
  else if(currentState == newState) 
    {
      return 5;
    }
  
  return 0;
}

int main() 
{ 

  int n;
  int i;
  int currentState,newState;
  int total;
#ifdef FILEIO
  freopen("in.txt","r",stdin); 
  freopen("out.txt","w",stdout); 
#endif

  scanf("%d",&n);
  currentState = 0;
  while(n != 0)
    {
	  total=0;
	  currentState=0;
      for(i = 0;i<n;i++)
        {
          scanf("%d",&newState);
          total += TimeSpan(currentState,newState);
          currentState = newState;
        }
      printf("%d\n",total);
      scanf("%d",&n);      
    }

#ifdef FILEIO
  fclose(stdin);
  fclose(stdout);
#endif
  
  return 0; 
} 
